package com.szosen.util;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.szosen.jkzj.R;
import com.szosen.json.PastHistorylist;

	public class jwsColmunAdapter extends BaseAdapter {

		private static final int LENGTH = 4;
		private List<String[]> mData;
		private Context mContext;
		private Holder holder;

		public jwsColmunAdapter(Context context,List<String[]> data) {
			mContext = context;
			mData = data;
		}

		@Override
		public int getCount() {
			return mData.size();
		}

		@Override
		public Object getItem(int position) {
			return mData.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		public void deleteItemId(int position) {
			mData.remove(position);
		}

		public void addItem(String[] data) {
			mData.add(data);
		}

		public List<String[]> getListItem() {
			return mData;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			String[] item = mData.get(position);
			if (convertView == null) {
				holder = new Holder();
				holder.dataET = new TextView[LENGTH];
				LayoutInflater inflater = LayoutInflater.from(mContext);
				convertView = inflater
						.inflate(R.layout.jws_lv_item_layout, null);
				holder.dataET[0] = (TextView) convertView.findViewById(R.id.jsw_lv_item_jwslv);
				holder.dataET[1] = (TextView) convertView.findViewById(R.id.jsw_lv_item_jbmc);
				holder.dataET[2] = (TextView) convertView.findViewById(R.id.jsw_lv_item_gcff);
				holder.dataET[3] = (TextView) convertView.findViewById(R.id.jsw_lv_item_zgqk);
				holder.layout = (LinearLayout) convertView
						.findViewById(R.id.list_item_four_layout);
				convertView.setTag(holder);
			} else {
				holder = (Holder) convertView.getTag();
			}
			holder.dataET[0].setText(item[0]);
			holder.dataET[1].setText(item[1]);
			holder.dataET[2].setText(item[2]);
			holder.dataET[3].setText(item[3]);
			return convertView;
		}

		public class Holder {
			public TextView[] dataET;
			public LinearLayout layout;

			private void setTextColor(int color) {
				for (int i = 0; i < dataET.length; i++) {
					dataET[i].setTextColor(color);
				}
			}
		}
	}
